/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.server.frame.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import offset.nodes.server.controller.AuthenticatingAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Walter L�tgenau
 */
public class FrameAction extends AuthenticatingAction {
    public static final String PAR_FRAME = "frame";
    static Logger logger = LoggerFactory.getLogger(FrameAction.class);
    
    @Override
    public ActionForward process(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        String frame = request.getParameter(PAR_FRAME);

        if (frame == null)
            return mapping.findForward(FrameForm.FRAMESET);
        else if (frame.equals(FrameForm.FRAME_TOOLBAR))
            return mapping.findForward(FrameForm.FRAME_TOOLBAR);
        else if (frame.equals(FrameForm.FRAME_ACTIONBAR))
            return mapping.findForward(FrameForm.FRAME_ACTIONBAR);
        else if (frame.equals(FrameForm.FRAME_FOOTER))
            return mapping.findForward(FrameForm.FRAME_FOOTER);

        return null;
    }

}
